! 数组链表，封装一下，类似数组构造器
module linked_list

    type :: list_t
        real, allocatable :: items(:)
    contains
        procedure :: init => init_list
        procedure :: push => push
    end type list_t

contains

    !> 初始化链表
    pure subroutine init_list(list)
        class(list_t), intent(inout) :: list
        list%items = [real ::]
    end subroutine init_list

    !> 添加元素
    pure subroutine push(list, item)
        class(list_t), intent(inout) :: list
        real, intent(in) :: item
        list%items = [list%items, item]
    end subroutine push

end module linked_list

program main

    use linked_list
    type(list_t) :: list
    integer :: ntimesteps
    real :: rand

    call random_number(rand)
    ntimesteps = nint(min(max(rand*50, 5.0), 50.0))

    call list%init()
    do i = 1, ntimesteps
        call random_number(rand)
        call list%push(rand)
    end do

    print *, list%items

end program main
